package com.sisgesbyte.services.sistema;

import java.util.Properties;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
public class SendMailTest {

	public static void main(String[] args) {
		
		Properties props = new Properties();
		props.put("mail.smtp.host", "smtp.gmail.com");
		props.put("mail.smtp.socketFactory.port", "465");
		props.put("mail.smtp.socketFactory.class",
				"javax.net.ssl.SSLSocketFactory");
		props.put("mail.smtp.auth", "true");
		props.put("mail.smtp.port", "465");
		//
		String  correos ="carla_cecilia84@hotmail.com,joseph19_20@hotmail.com";
		Session session = Session.getDefaultInstance(props,
			new javax.mail.Authenticator() {
				protected PasswordAuthentication getPasswordAuthentication() {
					return new PasswordAuthentication("jodavivi@gmail.com","@@genius");
				}
			});
 
		try {
 
			Message message = new MimeMessage(session);
			message.setFrom(new InternetAddress("jodavivi@gmail.com"));
			message.setRecipients(Message.RecipientType.BCC,
					InternetAddress.parse(correos));
			message.setSubject("OFERTAS 333");
			// Stilos: "<div style=\"color:red;\">BRIDGEYE</div>";
			String messagehtm = "<html><table><tr><td>Holaaaa</td><td>david</td></tr><tr><td>Villanueva</td><td>Villalobos</td></tr></table></html>";
			message.setContent(messagehtm, "text/html; charset=utf-8");
			
			Transport.send(message);
 
			System.out.println("Done");
 
		} catch (MessagingException e) {
			System.out.println("Error MessagingException : "+ e.getMessage());
			throw new RuntimeException(e);
		}catch(Exception e){
			System.out.println("Error Exception : "+ e.getMessage());
		}
		
	}

}
